
char* sortSentence(char* s) {
    int s_len = strlen(s);
    char* hash[11];
    int i;
    for (i = 0; i < 11; ++i) {
        hash[i] = NULL;
    }
    int pos;
    char* tail = s;
    i = 0;
    while (s[i] != '\0') {
        if (s[i] == ' ') {
            s[i] = '\0';
            pos = s[i - 1] - '0';
            s[i - 1] = ' ';
            hash[pos] = tail;
            tail = &s[i + 1];
        }
        ++i;
    }
    pos = s[i - 1] - '0';
    s[i - 1] = ' ';
    hash[pos] = tail;
    char* res = malloc((s_len + 1) * sizeof(char));
    memset(res, '\0', strlen(s) + 1);
    for (i = 0; i < 11; ++i) {
        if (hash[i]) {
            strcat(res, hash[i]);
        }
    }
    int res_len = strlen(res);
    res[res_len - 1] = '\0';
    return res;
}
